

using System;
using System.Collections.Generic;
using System.Text;
using ECommerce.DAL;
using System.Data.SqlClient;
using System.Data;

namespace Entity
{
    [System.ComponentModel.DataObject]
    public class TblCouponExtended : TblCoupon
    {
        public static CustomCollection<TblCoupon> GetNonDeletedCouponPaged(string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_COUPON_GET_NONDELETED_COUPON_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblCouponCollectionFromReader);
            CustomCollection<TblCoupon> objCollection = ((CustomCollection<TblCoupon>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
        public static int GetNonDeletedCouponCount()
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_COUPON_GET_NONDELETED_COUPON_COUNT);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static CustomCollection<TblCoupon> GetActiveCouponPaged(string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_COUPON_GET_ACTIVE_COUPON_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblCouponCollectionFromReader);
            CustomCollection<TblCoupon> objCollection = ((CustomCollection<TblCoupon>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
        public static int GetActiveCouponCount()
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_COUPON_GET_ACTIVE_COUPON_COUNT);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static CustomCollection<TblCoupon> GetNonDeletedCouponByCouponNamePaged(string couponName, string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@couponName", SqlDbType.VarChar, 500, ParameterDirection.Input, couponName);
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_COUPON_GET_NONDELETED_COUPON_BY_COUPONNAME_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblCouponCollectionFromReader);
            CustomCollection<TblCoupon> objCollection = ((CustomCollection<TblCoupon>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;

        }
        public static int GetNonDeletedCouponByCouponNameCount(string couponName)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@couponName", SqlDbType.VarChar, 500, ParameterDirection.Input, couponName);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_COUPON_GET_NONDELETED_COUPON_BY_COUPONNAME_COUNT);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static CustomCollection<TblCoupon> GetAllCouponByCouponNamePaged(string couponName, string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@couponName", SqlDbType.VarChar, 50, ParameterDirection.Input, couponName);
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_COUPON_GET_ALL_COUPON_BY_COUPONNAME_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblCouponCollectionFromReader);
            CustomCollection<TblCoupon> objCollection = ((CustomCollection<TblCoupon>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;

        }
        public static int GetAllCouponByCouponNameCount(string couponName)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@couponName", SqlDbType.VarChar, 50, ParameterDirection.Input, couponName);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_COUPON_GET_ALL_COUPON_BY_COUPONNAME_COUNT);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

       

        private const string SP_TBL_COUPON_GET_ALL_COUPON_BY_COUPONNAME_PAGED = "sp_TblCoupon_Get_All_Coupon_By_CouponName_Paged";
        private const string SP_TBL_COUPON_GET_ALL_COUPON_BY_COUPONNAME_COUNT = "sp_TblCoupon_Get_All_Coupon_By_CouponName_Count";

        private const string SP_TBL_COUPON_GET_ACTIVE_COUPON_PAGED = "sp_TblCoupon_Get_Active_Coupon_Paged";
        private const string SP_TBL_COUPON_GET_ACTIVE_COUPON_COUNT = "sp_TblCoupon_Get_Active_Coupon_Count";

        private const string SP_TBL_COUPON_GET_NONDELETED_COUPON_PAGED = "sp_TblCoupon_Get_NonDelete_Coupon_Paged";
        private const string SP_TBL_COUPON_GET_NONDELETED_COUPON_COUNT = "sp_TblCoupon_Get_NonDelete_Coupon_Count";

        private const string SP_TBL_COUPON_GET_NONDELETED_COUPON_BY_COUPONNAME_PAGED = "sp_TblCoupon_Get_NonDelete_Coupon_By_CouponName_Paged";
        private const string SP_TBL_COUPON_GET_NONDELETED_COUPON_BY_COUPONNAME_COUNT = "sp_TblCoupon_Get_NonDelete_Coupon_By_CouponName_Count";


    }
}

